package codes

import (
	"fmt"
)

type Level byte

const (
	Warn  Level = 0x01
	Error Level = 0x02
	Fatal Level = 0x03
)

func (level Level) String() string {
	switch level {
	case Warn:
		return "WARN"
	case Error:
		return "ERROR"
	case Fatal:
		return "FATAL"
	default:
		panic(fmt.Sprintf("level not defined:%d", level))
	}
}

type Code interface {
	//获取当前日志等级
	GetLevel() Level
	// 获取当前日志编号
	GetCode() uint32
	// 获取当前错误信息
	Error() string
	// 获取当前错误详细说明
	GetDetails() []string
	// Unwrap unwrap the error
	Unwrap() error
	// UnWrapError unwrap the error to get the error messages
	UnWrapError() string
	//添加详细说明
	WithDetails(details ...string) Code
	//添加错误
	Wrap(err error) Code
	//添加错误和详细说明
	WrapWithDetails(err error, details ...string) Code
	Send(ch chan Code) Code
}
